import myAxios from './myAxios';


//--------------------用户--------------------

//登陆注册：获取登录图形验证码
export const getLoginCaptcha = (random) => `api/ucenter/member/getVerifyCode?${random}`;

//登陆注册：获取注册手机验证码
export const getPhoneCaptcha = (phone) => myAxios.get(`api/ucenter/sms/send/${phone}`);

//登陆注册：登录
export const login = (mobile, password, code) => myAxios.post('api/ucenter/member/login', {
    mobile,
    password,
    code
});

//登陆注册：注册
export const register = (mobile, password, code, nickname) => myAxios.post('api/ucenter/member/register', {
    mobile,
    password,
    code,
    nickname
});

// 添加分组
export const addFenZu = (userId, fenZuName) => myAxios.post('api/ucenter/member/addFenZu', {
    userId,
    fenZuName
});

// 修改分组名
export const updateFenZuName = (userId, oldFenZu, newFenZu) => myAxios.post('api/ucenter/member/editFenZuName', {
    userId,
    oldFenZu,
    newFenZu
});

// 删除分组
export const deleteFenZu = (userId, fenZuName) => myAxios.post('api/ucenter/member/delFenZu', {
    userId,
    fenZuName
});

// 修改备注
export const modifyFriendBeiZhu = (friendId, friendBeiZhuName) => myAxios.post('api/ucenter/member/updateFriendBeiZhu', {
    friendId,
    friendBeiZhuName
});
// 设置分组
export const modifyFriendFenZu = (userId, friendId, newFenZuName) => myAxios.post('api/ucenter/member/modifyFriendFenZu', {
    userId,
    friendId,
    newFenZuName
});

// 设置反馈信息
export const addFeedBack = (userId, username, feedBackContent) => myAxios.post('api/ucenter/feedBack', {
    userId,
    username,
    feedBackContent
});

//--------------------聊天--------------------

// 获取验证消息列表
export const getMyValidateMessageList = (type, status) => myAxios.get(`/api/ucenter/validate/getMyValidateMessageList?validateType=${type}&status=${status}`);

export const getUserInfo = (userId) => myAxios.get(`api/ucenter/member/getUserInfo/${userId}`);

//获取好友列表
export const getMyFriendList = () => myAxios.get(`/api/ucenter/goodFriend/getMyFriendsList`);

//获取群聊列表
export const getMyGroupList = () => myAxios.get(`/api/ucenter/group/getMyGroupList`);

//获取我创建的群聊列表
export const getMyCreateGroupList = () => myAxios.get(`/api/ucenter/group/getMyCreateGroupList`);


//获取消息列表
export const getMyChatList = () => myAxios.get('/api/ucenter/message/messageListItem');

//获取好友聊天记录
export const getSingleChatHistory = (roomId, pageIndex, pageSize) => myAxios.get(`/api/ucenter/singleMessage/getRecentSingleMessages?roomId=${roomId}&pageIndex=${pageIndex}&pageSize=${pageSize}`);

//搜索用户
export const searchUser = (type, searchContent, pageIndex, pageSize) => myAxios.post('/api/ucenter/member/preFetchUser', {
    type,
    searchContent,
    pageIndex,
    pageSize
});

// 创建群聊
export const createGroup = (title, desc, img, holderUserId, holderName) => myAxios.post('api/ucenter/group/createGroup', {
    title,
    desc,
    img,
    holderUserId,
    holderName
});
//--------------------课程--------------------

//课程：根据大小分类获取课程列表（排序的字段,可以指定三个值 price（价格排序）createtime(创建时间排序) count(浏览数量排序)）
export const getCourseList = (mt, st, orderField, orderType) => myAxios.get('api/edu/course/list', {
    mt, st, orderField, orderType
});

//获取课程分类列表
export const getCourseCategories = () => myAxios.get('api/admin/edu/course/course_cate/list');

//课程详情：获取课程简要信息
export const getCourseBasicInfo = courseId => myAxios.get(`api/admin/edu/course/course_info/get/${courseId}`);

//课程详情：获取课程详细信息
export const getCourseDetailInfo = courseId => myAxios.get(`api/edu/detail/get/${courseId}`);

//课程详情：获取课程所有信息
export const getCourseAllInfo = courseId => myAxios.get(`api/edu/course/course_view/get/${courseId}`);

//课程详情：获取课程视频信息
export const getCourseVideoInfo = courseId => myAxios.get(`api/edu/video/getVideoByPlanId/${courseId}`);

//视频：获取视频播放凭证
export const getVideoAuth = videoId => myAxios.get(`api/vod/media/get_play_auth/${videoId}`);

export const getVideoByPlanId = planId => myAxios.get(`api/edu/video/getVideoByPlanId/${planId}`)

//课程详情：获取用户是否已收藏课程
export const getCourseCollectionStatus = courseId => myAxios.get(`/api/edu/collect/auth/is_collect/${courseId}`);

//收藏课程：收藏课程
export const addCourseToCollection = courseId => myAxios.post(`api/edu/collect/auth/save/${courseId}`);

//收藏课程：取消收藏课程
export const removeCourseInCollection = courseId => myAxios.delete(`api/edu/collect/auth/remove/${courseId}`);

//收藏课程：获取我的课程收藏夹
export const getCourseCollectionList = () => myAxios.get(`api/edu/collect/auth/list`);

//讲师详情：获取讲师信息
export const getTeacherAllInfo = teacherId => myAxios.get(`api/edu/teacher/get/${teacherId}`);

// 获取讲师对应的课程列表
export const getCourseListByTeacherId = (page, rows, keys) => myAxios.get(`api/edu/course/course_info/self/list/${page}/${rows}/${keys}`)


//--------------------专业--------------------

//专业：获取专业列表
export const getMajorList = () => myAxios.get(`api/major/content/list`);

//专业详情：获取专业详情信息
export const getMajorDetail = majorId => myAxios.get(`api/major/content/select/${majorId}`);

// 获取编程语言排行榜
export const getProgramData = () => myAxios.get(`api/major/lw/getAll`)


//--------------------搜索--------------------

//搜索：搜索课程
export const searchCourses = (page = 1, pageSize = 10, keyword, grade, price_min, price_max, sort) => myAxios.post(`api/search/course/list/get/${page}/${pageSize}`, {
    keyword,
    grade,
    price_min,
    price_max,
    sort
});

//搜索：搜索讲师
export const searchTeachers = (name, pageNum = 0, pageSize = 10) => myAxios.post(`api/edu/teacher/findAll/condition`, {
    name,
    pageNum,
    pageSize
});


//--------------------博客--------------------

// 获取博客列表
export const getBlogList = (pageHelp) => myAxios.post(`/api/blog/content/queryAll`, pageHelp)

// 获取分类列表(根据类别多少个博客进行排序)
export const getBlogCateList = () => myAxios.get(`/api/blog/content/cate/list`)

// 获取博客受欢迎top6(property是字段名) 进行条件过滤
export const getBolgListBySearch = (page, size, keys, property, userId) => myAxios.post(`/api/blog/content/queryAll`, {
    page,
    size,
    property,
    keys,
    userId
})

// 根据id查询博客详细信息
export const queryById = (id) => myAxios.get(`/api/blog/content/queryById/${id}`)


// 获取该博客的评论列表
export const getCommentList = (id) => myAxios.get(`/api/blog/comment/queryByBlogId/${id}`)

//--------------------oss--------------------

// 文件上传
export const uploadFile = (formatDate) => myAxios.post(`api/oss/file/upload`, formatDate)

//--------------------在线考试--------------------

// 获取在线考试信息
export const getExamInfo = (queryInfo) => myAxios.post(`/api/exam/get`, queryInfo)

// 根据id获取考试信息
export const getExamInfoById = id => myAxios.get(`/api/exam/${id}`)

// 查询所有考试信息

export const allExamInfo = () => myAxios.get(`/api/exam/list`)
// 根据id列表获取题目信息
export const getQuestionByIds = ids => myAxios.get(`/api/exam/question/list`, {
    params: {
        ids: ids
    }
})

// 添加考试记录
export const addExamRecord = examRecord => myAxios.post(`/api/exam/record/add`, examRecord)

// 获取考试中每一题的分数
export const getExamQuestionByExamId = examId => myAxios.get(`/api/exam/exam_question/getExamQuestionByExamId/${examId}`)

// 根据id获取考试记录
export const getExamRecordById = id => myAxios.get(`/api/exam/record/${id}`)

// 获取个人成绩
export const getMyGrade = queryInfo => myAxios.get(`/api/exam/record/myGrade`, {
    params: queryInfo
})

// 生成证书
export const getCertificate = queryInfo => myAxios.get(`/api/exam/record/certificate`, {
    params: queryInfo
})

// 按照类型获取题库问题总数
export const getBankHaveQuestionSumByType = queryInfo => myAxios.get(`/api/exam/question/bank/getBankHaveQuestionSumByType`, {
    params: queryInfo
})

// 根据题库id和题目类型获取题目信息 type(1单选 2多选 3判断)
export const getQuestionByBankIdAndType = queryInfo => myAxios.get(`/api/exam/question/bank/getQuestionByBankIdAndType`, {
    params: queryInfo
})

// 根据题目获取题库
export const getQuestionByBank = bankId => myAxios.get(`/api/exam/question/bank/question/list/bank/${bankId}`)